#ifndef SALECALCULATEWIDGET_H
#define SALECALCULATEWIDGET_H

#include <QDialog>
#include "dingdan.h"
#include "dingdanservice.h"
#include "userservice.h"

namespace Ui {
class SaleCalculateWidget;
}

class SaleCalculateWidget : public QDialog
{
    Q_OBJECT

public:
    explicit SaleCalculateWidget(QWidget *parent = nullptr);
    ~SaleCalculateWidget();

    void setWidgetType(Dingdan::DingdanType widgetType);

    void setTicketState(bool isTicket);

    void showWithDingdan(Dingdan *dingdan);

    void checkValue(QLineEdit *lineEdit);

signals:
    void calculateDingdanSuccess();

private slots:
    void on_lineEditSourceFreightPaid_editingFinished();

    void on_lineEditSourceFreightUnpaid_editingFinished();

    void on_lineEditTargetFreightPaid_editingFinished();

    void on_lineEditFreeTicket_editingFinished();

    void on_lineEditFreeMoney_editingFinished();

    void on_lineEditTicket_editingFinished();

    void on_lineEditMoney_editingFinished();

    void on_pushButtonCancel_clicked();

    void on_pushButtonSubmit_clicked();

private:
    Ui::SaleCalculateWidget *ui;
    Dingdan::DingdanType widgetType;

    Dingdan *dingdan;
    DingdanService dingdanService;
    UserService userService;
};

#endif // SALECALCULATEWIDGET_H
